import time

from selenium.webdriver.common.by import By
from selenium import webdriver
from Po126_0903.Base import Base

class Page2(Base):
    #进入框架
    # kj_loc=(By.XPATH,'//*[@id="x-URS-iframe1756899258471.6572"]')x-URS-iframe1756899258471.6572
    # kj_loc=(By.XPATH,'//iframe[start-with(@id,"x-URS-iframe175")]')
    kj_loc = (By.XPATH, '/html/body/div[3]/div[3]/div[1]/div/div[3]/div[1]/div[2]/iframe')
    def kj(self):
        self.frame(self.kj_loc)
    #输入账号
    user_loc=(By.NAME,'email')
    def username(self):
        self.send_keys(self.user_loc,'grq13381144084')
    #输入密码
    pass_loc=(By.NAME,'password')
    def password(self):
        self.send_keys(self.pass_loc,'grq200566++')
    #点击登录按钮
    an_loc=(By.XPATH,'//*[@id="dologin"]')
    def anniu(self):
        self.click(self.an_loc)
    #断言1
    dy1_loc=(By.XPATH,'/html/body/div[2]/div[1]/div/div/div[3]/div[1]/div[1]/div[3]/div[1]/div[1]/div/span[1]')
    def dy1(self):
        return self.text(self.dy1_loc)
    #点击写信
    xiexin_loc=(By.XPATH,'//*[@id="_mail_component_98_98"]/span[2]')
    def xiexin(self):
        self.click(self.xiexin_loc)
    #输入收件人邮箱
    youxiang_loc=(By.XPATH,'/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[1]/div[1]/div/div[2]/div/input')
    def youxiang(self):
        self.send_keys(self.youxiang_loc,'1522057104@qq.com')
    #输入主题
    zhuti_loc=(By.XPATH,'/html/body/div[2]/div[1]/div[2]/div[1]/section/header/div[2]/div[1]/div/div/input')
    def zhuti(self):
        self.send_keys(self.zhuti_loc,'126邮箱')
    #点击发送
    fasong_loc=(By.XPATH,'/html/body/div[2]/div[1]/div[2]/header/div/div[1]/div/span[2]')
    def fasong(self):
        self.click(self.fasong_loc)

    def luoji_126_xiexin(self):
        self.open_url('https://www.126.com/')
        time.sleep(5)
        self.kj()
        self.username()
        self.password()
        self.anniu()
        self.frame_content()
        time.sleep(5)
        self.xiexin()
        self.youxiang()
        self.zhuti()
        self.fasong()